package com.suep.lesson_manage.repository;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.suep.lesson_manage.model.LessonSection;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public interface LessonRepository extends BaseMapper<LessonSection> {
    @Select("select * from LessonSection where ${ew.SQLSegment}")
    @Results({
            @Result(property = "section_id", column = "section_id"),
            @Result(property = "section_name", column = "section_name"),
            @Result(property = "start_time", column = "start_time"),
            @Result(property = "end_time", column = "end_time"),
            @Result(property = "duration", column = "duration"),

    })
    List<LessonSection> selectByid(@Param("ew") Wrapper<LessonSection> queryWrapper);
    @Select("select * from LessonSection")
    @Results({
            @Result(property = "section_id", column = "section_id"),
            @Result(property = "section_name", column = "section_name"),
            @Result(property = "start_time", column = "start_time"),
            @Result(property = "end_time", column = "end_time"),
            @Result(property = "duration", column = "duration"),
    })
    List<LessonSection> selectAll();

    // 自定义获取课节表行数的方法声明
    @Select("SELECT COUNT(*) FROM LessonSection")
    long count();

}
